/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.core;

import org.eclipse.emf.ecore.EClass;
import org.w3c.dom.Element;

import edu.pku.sei.modeler.model.xml.XMLUtility;

/**
 * @author zl
 * @author xy
 *
 */
public class MetaParameter extends MetaTypedElement {
	MetaOperation containingOperation;
	
	public MetaOperation getContainingOperation() {
		return containingOperation;
	}
	
	void setContainingOperation(MetaOperation newContainingOperation) {
		MetaOperation oldContainingOperation = containingOperation;
		containingOperation = newContainingOperation;
		firePropertyChange(CorePackage.PARAMETER_CONTAININGOPERATION, 
				oldContainingOperation, newContainingOperation);
		
	}
	
	public void serialize(Element root) {
		super.serialize(root);
		XMLUtility.xmlInstance.serializeNodeNotContain(root, CorePackage.PARAMETER_CONTAININGOPERATION, containingOperation);
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		containingOperation = (MetaOperation)XMLUtility.xmlInstance.deSerializeNodeNotContain(root, CorePackage.PARAMETER_CONTAININGOPERATION,this);
	}
	
	@Override
	protected EClass eStaticClass() {
		return EMetaModelPackage.Literals.EMETA_PARAMETER;
	}
	
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EMetaModelPackage.EMETA_PARAMETER__CONTAINING_OPERATION:
				if (resolve) return getContainingOperation();
				return getContainingOperation();
		}
		return super.eGet(featureID, resolve, coreType);
	}
}
